/**
 * 
 */
package com.jie.eclipse.pan.config;

import java.util.Enumeration;

import com.jie.eclipse.pan.data.BaseDataEntities;
import com.jie.eclipse.pan.data.BaseDataEntity;
import com.jie.eclipse.pan.utils.StringHelper;
import com.jie.eclipse.pan.xml.XMLConfig;
import com.jie.eclipse.pan.xml.XMLNode;

/**
 * @author yanjie
 *
 */
public class BaseConfig extends XMLConfig{
	public final static String TAG_LABLE = "labelText";
	private String nodeName = "node";
	
	/**
	 * 
	 */
	public BaseConfig() {
		this.SetExtValue(TAG_LABLE, "BaseNode");
		init();
	}
	
	public void loadConfig(BaseDataEntity data){
		Enumeration keys = data.getParamList().keys();
		while (keys.hasMoreElements()){
			Object objKey = keys.nextElement();
			Object objValue = data.getParamList().get(objKey);
			OnSetProperty((String) objKey, objValue);
		}
	}
	
	public void OnSetProperty(String strName, Object objvalue) {
		this.spov(strName, objvalue);
	}
	
	public String getNodeName(){
		return this.nodeName;
	}
	
	public void setNodeName(String nodeName) {
		this.nodeName = nodeName;
	}
	
	
	/**
	 * @param node
	 * 填充xml对像
	 */
	@SuppressWarnings("rawtypes")
	public void FillXmlNode(XMLNode root){
		if(this.extAttrList == null) return;
		Enumeration keys = this.extAttrList.keys();
		while (keys.hasMoreElements()){
			String key = StringHelper.getValue(keys.nextElement());
			String strValue = this.GetExtValue(key, "");
			root.SetValue(key, strValue);
		}
	}
	
	@Override
	protected Object CreateCloneObject() {
		return new BaseConfig();
	}
	
	public void init(){
		
	}
}
